#ifndef AEROSOLWIDGET_H
#define AEROSOLWIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QList>
#include <widget.h>
#include <QPropertyAnimation>
#include <QEventLoop>
#include <QEasingCurve>
#include <movebutton.h>

class AerosolWidget : QObject
{
    Q_OBJECT
public:
    enum DIRECTION{
        UP,
        DOWN,
        LEFT,
        RIGHT
    };

    AerosolWidget(QWidget * parent);

    /**
     * @brief getSubButtons     获取所有子button
     * @return
     */
    QList<QPushButton *> getSubButtons() const;

    /**
     * @brief setSubButtons         设置子button
     * @param value
     */
    void setSubButtons(const QList<QPushButton *> &value);

    /**
     * @brief getRadius     获取半径
     * @return
     */
    int getRadius() const;

    /**
     * @brief setRadius     设置半径
     * @param value
     */
    void setRadius(int value);

    /**
     * @brief getButtonSize     获取button尺寸
     * @return
     */
    int getButtonSize() const;

    /**
     * @brief setButtonSize     设置button尺寸
     * @param value
     */
    void setButtonSize(int value);

    /**
     * @brief getParent         获取父窗口
     * @return
     */
    QWidget *getParent() const;

    /**
     * @brief setButtonStyle        设置button样式表
     * @param style
     */
    void setButtonStyle(const QString& style);

    /**
     * @brief isStretch    伸展状态
     * @return
     */
    bool isStretch() const;

    /**
     * @brief setMainButtonText     设置主button text
     * @param text
     */
    void setMainButtonText(const QString& text);

    /**
     * @brief setMainButton     设置主button
     * @param button
     */
    void setMainButton(MoveButton *button);

    /**
     * @brief getDirection      获取方向
     * @return
     */
    AerosolWidget::DIRECTION getDirection() const;

    /**
     * @brief setDirection      设置方向
     * @param value
     */
    void setDirection(const AerosolWidget::DIRECTION &value);

    /**
     * @brief showCenter        显示收缩
     */
    void showCenter();

    /**
     * @brief showStretch       显示伸展
     */
    void showStretch();

    /**
     * @brief setPos        设置位置
     * @param value
     */
    void setPos(const int &value);

    /**
     * @brief setMoveEnable     设置窗口可移动
     * @param enable
     */
    void setMoveEnable(bool enable);
    bool moveEnabled();

    void setOpacity(float value);

    int getDuration() const;
    void setDuration(int value);

    QEasingCurve getCurve() const;
    void setCurve(const QEasingCurve &value);

protected:

private:
    MoveButton* mainButton;    //主悬浮按钮
    QList<QPushButton*> subButtons;
    QList<float> buttonPosAngle;
    QList<QPoint> buttonPoints;
    QWidget * parent;
    QPoint currentPos;
    float opacity;
    int duration;
    QEasingCurve curve;

    int radius;      //半径
    int buttonSize;    //button尺寸
    bool IsStretch;       //伸展状态
    QString style;
    DIRECTION direction;    //方向
    void setButtonStyle();
    void calsPosition();
    void loops(QPropertyAnimation* animation);
private slots:
    void showState();
    void centreButtonMoved();
    void centreButtonDocked(int);
public slots:
    /**
     * @brief stretchAnimation      伸展动画
     */
    void stretchAnimation();

    /**
     * @brief contractAnimation     收缩动画
     */
    void contractAnimation();

};

#endif // AEROSOLWIDGET_H
